function getHotArticle() {
    const hots = $('#hotList')
    $.get(root + '/index/article/hot', function(data) {
        hots.html('')
        data.data.forEach(el => {
            hots.append(setHotArticles(el.articleId, el.articleTitle))
    })
    })
}

function setHotArticles(id, title) {
    const href = 'infopic.html?id=' + id
    const msg = '<li><a href="' + href + '" target="_blank">' + title + '</a></li>'
    return msg
}

function hrefFun(id) {
    typeId = 'typeId=' + id
    toIndex(typeId)
    getNewArticle(1)
}

function getTypes() {
    const types = $('#typeList')
    const url = root + '/type/get/all'
    $.get(url, function (result) {
        types.html('')
        console.log(result)
        result.data.forEach(el => {
            types.append(setTypes(el.typeId, el.typeName, el.size))
        })
    })
}

function setTypes(id, name, size) {
    const msg = '<li style="cursor: pointer;"><a onclick="hrefFun(' + id + ')">' + name + ' ( ' + size + ' )</a></li>'
    return msg
}

function search() {
    const searchText = $('#searchText').val().trim()
    window.location.href = 'search.html?search=' + searchText
}

getTypes()
getHotArticle()